package com.danco.training.zaneuskaya.property;


import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;



public class PropertyReader {
	
	
	private Properties props;
	private InputStream input;
	private static String filename = "dependency.properties";
	private static PropertyReader propertyReaderInstance;
	
	private static final Logger logger = Logger.getLogger(PropertyReader.class);
	
	private PropertyReader(){
			
		props = new Properties();
	   	
		input = getClass().getClassLoader().getResourceAsStream(getFilename());
		try {
			props.load(input);
		} catch (IOException e) {
			logger.error(e.getMessage(), e);
		}
			
	 }

	public static PropertyReader getPropertyReaderInstance() {
		if (propertyReaderInstance == null){
			propertyReaderInstance = new PropertyReader();
		}
		return propertyReaderInstance;
	}

	public Properties getProps() {
		 try {

			input.close();
		} catch (IOException e) {
			logger.error(e.getMessage(), e);
		}
		
		return props;
	}

	public String getFilename() {
		return filename;
	}

	public static void setFilename(String filename) {
		PropertyReader.filename = filename;
	}

	

		 
 

   
}

